package com.czm.art_light.controller;

import com.czm.art_light.constant.ApiRouterConsts;
import com.czm.art_light.entity.ArtTopic;
import com.czm.art_light.param.request.ArtInfoReqDto;
import com.czm.art_light.param.request.ArtSearchReqDto;
import com.czm.art_light.param.request.PageReqDto;
import com.czm.art_light.param.response.ArtInfoRespDto;
import com.czm.art_light.param.response.ArtTopicBasicInfoRespDto;
import com.czm.art_light.param.response.RestResp;
import com.czm.art_light.service.ArtTopicService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 话题信息 API 控制器
 */
@Tag(name = "话题管理", description = "话题相关接口")
@RestController
@RequestMapping(ApiRouterConsts.TOPIC_API_URL_PREFIX)
public class ArtTopicController {

    @Autowired
    private ArtTopicService artTopicService;

    /**
     * 获取话题信息 根据id以及分页的信息
     */
    @Operation(summary = "获取话题信息", description = "根据id以及分页的信息")
    @PostMapping("/getArtTopicById")
    public RestResp<ArtInfoRespDto> getArtTopicById(@Valid @RequestBody ArtInfoReqDto artInfoReqDto) {
        return RestResp.ok(artTopicService.getById(artInfoReqDto));
    }

    /**
     * 获取所有的话题基本信息
     */
    @Operation(summary = "获取所有的话题基本信息")
    @PostMapping("/getAllArtTopic")
    public RestResp<List<ArtTopicBasicInfoRespDto>> getAllArtTopic(@RequestBody PageReqDto pageReqDto) {
        List<ArtTopicBasicInfoRespDto> artTopicList = artTopicService.list(pageReqDto);
        return RestResp.ok(artTopicList);
    }
}